package main.java.com.rmisorter;
import java.io.Serializable;
import java.lang.reflect.Field;

@SuppressWarnings({"rawtypes", "unused", "unchecked"})
public class Person implements Comparable<Person>, Serializable {
	private static final long serialVersionUID = 1L;
	private Comparable lastName, age;
	
	public Person(String lastName, int age) {
		this.lastName = lastName;
		this.age = age;
	}

	public Comparable getLastName() {
		return this.lastName;
	}

	public Comparable getAge() {
		return this.age;
	}
	
	@Override
	public int compareTo(Person anotherPerson) {
		int compare = compareLastName(anotherPerson.getLastName());
		
		if (compare == 0) {
			compare = compareAge(anotherPerson.getAge()); 
		}
		
		return compare;
	}
	
	private int compareLastName(Comparable lastName) {
		return this.lastName.compareTo(lastName); 
	}
	
	private int compareAge(Comparable age) {
		return this.getAge().compareTo(age); 
	}
	
}
